package com.example.administrator.zhongyichou.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.example.administrator.zhongyichou.net.protocol.WaitPayProtocol;
import com.example.administrator.zhongyichou.R;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by lichenyu on 2017/12/6.
 * 描述：
 */

public class WaitPayListAdapter extends ListBaseAdapter {
    public WaitPayListAdapter(Context mContext, List list) {
        super(mContext, list);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if (convertView == null) {
            convertView = LayoutInflater.from(getContext()).inflate(R.layout.wait_pay_list_item, null);
            holder = new ViewHolder(convertView);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        WaitPayProtocol.DataBean.UserListBean bean = (WaitPayProtocol.DataBean.UserListBean) getData(position);
        holder.txtName.setText(bean.getName());
        holder.txtType.setText(bean.getValue().get(0).getType_title());
        holder.txtMoney.setText(bean.getValue().get(0).getMember_fee() + "");
        if (bean.getValue().size() == 2) {
            holder.txtType1.setVisibility(View.VISIBLE);
            holder.txtType1.setText(bean.getValue().get(1).getType_title());
            holder.txtMoney1.setVisibility(View.VISIBLE);
            holder.txtMoney1.setText(bean.getValue().get(1).getMember_fee() + "");
        } else {
            holder.txtType1.setVisibility(View.GONE);
            holder.txtMoney1.setVisibility(View.GONE);
        }
        return convertView;
    }

    static class ViewHolder {
        @BindView(R.id.txt_name)
        TextView txtName;
        @BindView(R.id.txt_type)
        TextView txtType;
        @BindView(R.id.txt_type1)
        TextView txtType1;
        @BindView(R.id.txt_money)
        TextView txtMoney;
        @BindView(R.id.txt_money1)
        TextView txtMoney1;

        ViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
}
